
#include "../include/nosie.glsl"

varying vec3 vPosition;
varying vec3 vInstanceColor;
varying vec2 vUv;
varying float waveParam;
varying float npParam;

varying float randomNum01;
varying float randomNum02;
varying float randomNum03;

uniform sampler2D aoMap;
uniform vec3 uWaveColor;
uniform float uWaveIntensity;
uniform float uColorIntensity;
uniform float uPercent;
uniform float uTime;

#define PI 3.1415926535

void main() {
    float dis = distance(gl_PointCoord, vec2(0.5));
    float op = uPercent * 0.5;
    if (dis > op) discard;

    float disToCamera = distance(vPosition, cameraPosition.xyz);
    float disToCenterX = abs(vPosition.x);
    if (randomNum01 > smoothstep(75., 10., disToCenterX)) discard;

    vec3 color = mix(vInstanceColor * uColorIntensity * (1. + 2. * pow(randomNum02, 5.) + 300. * pow(clamp(randomNum03, 0., 1.), 8.)), uWaveColor * uWaveIntensity, vec3(waveParam));

    gl_FragColor = vec4(vec3(mix(vec3(0.3, 0.5, 0.6) * (1. + 100. * pow(clamp(randomNum03, 0., 1.), 8.)), color, vec3(npParam))), 1.);
    gl_FragColor.rgb *= texture2D(aoMap, vec2(vPosition.x, -vPosition.z) / 3.97104 * 0.5 + 0.5).r;
}
